/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.generator.command;

import ru.jSkyRoom.interfaces.JSkyMod;
import ru.jSkyRoom.interfaces.major.Major;
import ru.jSkyRoom.interfaces.additional.HasTemplate;

/**
 *
 * @author Rakev
 */
public class CreationWithTemplateCommand<T extends Major> extends CreationCommand<T> {

    public CreationWithTemplateCommand(JSkyMod editingMod, EdidGenerationByBaseStrategy edidGenerator) {
        super(editingMod, edidGenerator);
    }

    @Override
    public T apply(T baseItem) {
        T genetatedItem = super.apply(baseItem);
        if (genetatedItem instanceof HasTemplate) {
            ((HasTemplate) genetatedItem).setTemplate(baseItem);
        }
        return genetatedItem;
    }
}
